﻿<Window x:Class="Test_TabDragDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:hub="http://www.quickzip.org/UIEventHub"
        Title="MainWindow" Height="350" Width="525">
    <DockPanel>
        <TextBlock DockPanel.Dock="Top" TextWrapping="Wrap" >
            This samples uses UIEventHub's DragDropLiteEventProcessor to perform tab rearrangement through drag and drop.  
            For touch support please press and hold until rectangle box shown.  
            TabItem does not support placeholder, it requires TabControlEx, see TestTemplate.WPF demo.
        </TextBlock>

        <TextBlock DockPanel.Dock="Bottom" TextWrapping="Wrap" >
            To use this EventProcessor all you need to : 
            Implement ISupportDragHelper and ITabControlViewModel interface in your TabControlViewModel.  
            Implement IDraggable, ISelectable and ISupportDropHelper interface in your TabViewModel.  
            Enable the processor in xaml.
        </TextBlock>

        <TabControl x:Name="tabControl1" Margin="5" Grid.Row="1"
                             SelectedIndex="{Binding SelectedIndex}"
                             ItemsSource="{Binding Items}" >
            <TabControl.ItemContainerStyle>

                <Style TargetType="{x:Type TabItem}" >
                    <Setter Property="IsSelected" Value="{Binding IsSelected}" />
                    <!--TabItemEx's properties -->
                    <!--<Setter Property="Opacity" Value="{Binding HeaderOpacity}" />-->
                    <!--<Setter Property="ShowPlaceHolder" Value="{Binding DropHelper.ShowPlaceHolder}" />-->
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding DropHelper.ShowPlaceHolder}" Value="True">
                            <Setter Property="Background" Value="Gray" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </TabControl.ItemContainerStyle>
            <TabControl.ItemTemplate>
                <DataTemplate>
                    <TextBlock x:Name="tb" Text="{Binding Header}" AllowDrop="True" />
                    <DataTemplate.Triggers>
                        <DataTrigger Binding="{Binding IsDraggingOver}" Value="True">
                            <Setter TargetName="tb" Property="Foreground" Value="Blue" />
                        </DataTrigger>
                    </DataTemplate.Triggers>
                </DataTemplate>
            </TabControl.ItemTemplate>
            <TabControl.LayoutTransform>
                <ScaleTransform ScaleX="1" ScaleY="1" />
            </TabControl.LayoutTransform>
            <hub:UIEventAdapter.Processors>
                <hub:DragDropLiteEventProcessor EnableMouse="True" EnableTouch="True" 
                                               EnableDrag="True" EnableDrop="True" />
                <!--<hub:DragDropEventProcessor EnableDrag="True" EnableDrop="True" TargetName="HeaderPanel" />-->
            </hub:UIEventAdapter.Processors>
        </TabControl>
    </DockPanel>
</Window>
